
const HeightItem = 100;
const Gap = 5;
cc.Class({
    extends: cc.Component,

    properties: {
        lb_welcome:cc.Label,
        nd_content:cc.Node,
        pf_item:cc.Prefab,
    },

    // LIFE-CYCLE CALLBACKS:


    initWithAllData(data){
        let lstData = data.rows;
        let len = lstData.length;
        let totalHeight = (Gap + HeightItem) * len;
        this.nd_content.height = totalHeight;
        lstData.forEach((itemData,idx)=>{
           let nd = cc.instantiate(this.pf_item);
           nd.setParent(this.nd_content);
           nd.setPosition(0,-(Gap + HeightItem) * idx - HeightItem/2);

           let item = nd.getComponent('item');
           item.initWithData(itemData,idx);
        });

        this.lb_welcome.string = `欢迎${data.uname}`;
    },

    btn_addClicked(){
        G.winMgr.showAddLayer();
    },

    btn_logoutClicked(){
        G.allData = null;
        G.gameCtrl.naviToLoginLayer();
    },
});
